package com.biejiaogroup.librarymanager.controller;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @Description: 登出
 * @Author: JesseChan
 * @Date: 2022/5/14
 */
@WebServlet("/logout")
public class LogoutServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        PrintWriter out = response.getWriter();
        try
        {
            request.getSession().invalidate();
            out.print("success");
        }
        catch (Exception e)
        {
            e.printStackTrace();
            out.print("fail");
        }

    }
}
